#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=Datapad_32bit.exe
#AutoIt3Wrapper_Outfile_x64=Datapad_64bit.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Comment=Datapad
#AutoIt3Wrapper_Res_Description=Datapad
#AutoIt3Wrapper_Res_Fileversion=0.5.4.0
#AutoIt3Wrapper_Res_LegalCopyright=Fade of Star Citizen Forums
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         Fade

 Script Function:
	Provide information on all topics in Star Citizen.

#ce ----------------------------------------------------------------------------

; Progress bar color: http://www.autoitscript.com/forum/topic/125085-set-color/

#Include <File.au3>
#Include <Array.au3>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

#include "xmpp_chat.au3"

Global $Combo1, $ComboX1

Global $Checkbox1, $Checkbox2, $Checkbox3, $Checkbox4, $Checkbox6
Global $ButtonA4, $ButtonA1
Global $InputX9, $InputX10, $InputX11, $InputX12

Global $Form2, $PicF1, $ButtonF1, $ButtonF2

Global $handle

Global $ComboG1, $REQDATA, $valueC

Global $Input1, $Input2, $Input3, $Input4, $Input5
Global $Input10, $Input11, $Input12, $Input13, $Input14, $InputG1

Global $REQDATA[30]

Global $previousCValue[30]

Global $lowestvaluereq[30]

$files = _FileListToArray("data\ships\Aurora ES\3D View\")
Global $ButtonF2, $ButtonF1
$count = 1


#Region ### START Koda GUI section ### Form=
$datapad_main = GUICreate("Citizen Datapad", 501, 438, -1, -1)
$Pic1 = GUICtrlCreatePic("data\launch\header.jpg", 0, 0, 500, 100)
$Pic2 = GUICtrlCreatePic("data\launch\side.jpg", 0, 100, 308, 337)
$ButtonZ1 = GUICtrlCreateButton("Ship Database (SDB)", 320, 112, 171, 33)
$ButtonZ2 = GUICtrlCreateButton("Economic Calculator (EC)", 320, 160, 171, 33)
$ButtonZ3 = GUICtrlCreateButton("Production Manager (PM)", 320, 208, 171, 33)
$ButtonZ4 = GUICtrlCreateButton("Mining Prospector (MP)", 320, 256, 171, 33)
$Button91 = GUICtrlCreateButton("Exit", 360, 400, 99, 25)
$ButtonZ5 = GUICtrlCreateButton("XMPP Chat (XC)", 320, 304, 171, 33)
$ButtonZ6 = GUICtrlCreateButton("Star Map (SM)", 320, 352, 171, 33)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $ButtonZ1
			GUISetState(@SW_MINIMIZE, $datapad_main)
			ShipDB()
			GUISetState(@SW_RESTORE, $datapad_main)
		Case $ButtonZ2
			GUISetState(@SW_MINIMIZE, $datapad_main)
			ECCALC()
			GUISetState(@SW_RESTORE, $datapad_main)
		Case $ButtonZ3
			GUISetState(@SW_MINIMIZE, $datapad_main)
			Production()
			GUISetState(@SW_RESTORE, $datapad_main)
		Case $ButtonZ4
			GUISetState(@SW_MINIMIZE, $datapad_main)
			Prospector()
			GUISetState(@SW_RESTORE, $datapad_main)
		Case $ButtonZ5
			GUISetState(@SW_MINIMIZE, $datapad_main)
			xmpp_startlogin()
			GUISetState(@SW_RESTORE, $datapad_main)
		Case $Button91
			Exit
	EndSwitch
WEnd

Func ECCALC()
	#Region ### START Koda GUI section ### Form=
	$ec_form_1 = GUICreate("Economic Calculator (EC)", 501, 438, -1, -1)
	$Pic1 = GUICtrlCreatePic("data\launch\ec_header.jpg", 0, 0, 500, 100)
	$Input2 = GUICtrlCreateInput("", 144, 112, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input3 = GUICtrlCreateInput("", 144, 136, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input4 = GUICtrlCreateInput("", 144, 160, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input5 = GUICtrlCreateInput("", 152, 200, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input6 = GUICtrlCreateInput("", 152, 224, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input7 = GUICtrlCreateInput("", 152, 248, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input8 = GUICtrlCreateInput("", 159, 287, 105, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
	$Input1 = GUICtrlCreateInput("", 144, 336, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY,$ES_NUMBER))
	$ButtonA3 = GUICtrlCreateButton("Calculate Node Output", 64, 368, 147, 25)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetState(-1, $GUI_DISABLE)
	$LabelY2 = GUICtrlCreateLabel("Production per cycle [P]:", 8, 336, 132, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label2 = GUICtrlCreateLabel("Number of workers:", 8, 112, 110, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label3 = GUICtrlCreateLabel("Required workers:", 8, 136, 103, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label4 = GUICtrlCreateLabel("Morale (%):", 8, 160, 66, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label5 = GUICtrlCreateLabel("Size of facility:", 8, 200, 83, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label6 = GUICtrlCreateLabel("Quality of equipment:", 8, 224, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label7 = GUICtrlCreateLabel("Max. Qual. of equipment:", 8, 248, 141, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label8 = GUICtrlCreateLabel("Material co-effecient [MC]:", 7, 287, 149, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Group1 = GUICtrlCreateGroup("Trend Prediction (TP)", 280, 104, 217, 121)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ButtonA1 = GUICtrlCreateButton("Generate Trend", 392, 192, 99, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Checkbox1 = GUICtrlCreateCheckbox("MC Decay", 288, 128, 81, 17)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$InputX9 = GUICtrlCreateInput("", 416, 128, 73, 22)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$InputX10 = GUICtrlCreateInput("", 416, 160, 73, 22)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Checkbox2 = GUICtrlCreateCheckbox("Morale Decay", 288, 160, 97, 17)
	GUICtrlSetState(-1, $GUI_DISABLE)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Group2 = GUICtrlCreateGroup("Unit Profit Prediction (UPP)", 280, 240, 217, 193)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ButtonA4 = GUICtrlCreateButton("Generate Prediction", 360, 400, 131, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Checkbox3 = GUICtrlCreateCheckbox("Use [P] Value", 288, 264, 121, 17)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$InputX11 = GUICtrlCreateInput("", 416, 264, 73, 22)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Checkbox4 = GUICtrlCreateCheckbox("Use system constant", 288, 320, 137, 17)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$ComboX1 = GUICtrlCreateCombo("ComboX1", 304, 344, 185, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label1 = GUICtrlCreateLabel("Cycle production costs:", 288, 288, 127, 18)
	$InputX12 = GUICtrlCreateInput("", 416, 288, 73, 22)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Checkbox6 = GUICtrlCreateCheckbox("Use system piracy constant", 288, 376, 201, 17)
	GUICtrlSetState(-1, $GUI_DISABLE)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Label9 = GUICtrlCreateLabel("Equation: P = M * E *MC", 7, 409, 124, 18)
	GUICtrlSetFont(-1, 9, 400, 2, "Calibri Light")
	$Label10 = GUICtrlCreateLabel("Help Manual Link", 184, 408, 88, 18)
	GUICtrlSetFont(-1, 9, 400, 2, "Calibri")
	GUICtrlSetColor(-1, 0x0000FF)
	GUICtrlSetCursor (-1, 0)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				$iMsgBoxAnswer = MsgBox(292,"Closing Dialog","Are you sure you want to close this dialog?" & @CRLF & "All work will be lost if it wasn't saved.")
				Select
					Case $iMsgBoxAnswer = 6 ;Yes
						GUIDelete($ec_form_1)
						ExitLoop
					Case $iMsgBoxAnswer = 7 ;No
						; Nothing
				EndSelect
			Case $ButtonA3
				; 2 worker num
				; 3 required workers
				; 4 morale
				; 5 fac size
				; 6 equip quality
				; 7 equip max quality
				; 8 MC

				; P = M * E *(MC)
				$M = (GUICtrlRead($Input2) / GUICtrlRead($Input3)) * GUICtrlRead($Input4)
				$E = GUICtrlRead($Input5) * (GUICtrlRead($Input6)/GUICtrlRead($Input7))

				$MC = GUICtrlRead($Input8)

				$P = $M * $E * $MC

				GUICtrlSetData($Input1, $P)
			Case $Label10
				OpenUrl("http://code.google.com/p/star-datapad/wiki/EconomicCalculator")
		EndSwitch

		; Check for compute P button
		If (GUICtrlRead($Input2) = 0) Or (GUICtrlRead($Input3) = 0) Or (GUICtrlRead($Input4) = 0) Or (GUICtrlRead($Input5) = 0) Or (GUICtrlRead($Input6) = 0) Or (GUICtrlRead($Input7) = 0) Or (GUICtrlRead($Input8) = 0) Then
			; Do nothing until data is entered in every box..
			GUICtrlSetState($ButtonA3, $GUI_DISABLE)
		Else
			GUICtrlSetState($ButtonA3, $GUI_ENABLE)
		EndIf
		; -----------

		; Check for trend and profit calc groups
		If GUICtrlRead($Input1) = 0 Then
			$disable = True
		Else
			$disable = False
		EndIf

		If $disable = True Then
			gui1disable()
		Else
			gui1enable()
		EndIf

		Sleep(100)
	WEnd
EndFunc

Func Production()
	#Region ### START Koda GUI section ### Form=
	$pm_form = GUICreate("Production Manager (PM)", 501, 618, -1, -1)
	$Pic1 = GUICtrlCreatePic("data\launch\pm_header.jpg", 0, 0, 500, 100)
	$LabelG2 = GUICtrlCreateLabel("Help Manual Link", 8, 592, 88, 18)
	GUICtrlSetFont(-1, 9, 400, 2, "Calibri")
	GUICtrlSetColor(-1, 0x0000FF)
	GUICtrlSetCursor (-1, 0)
	$LabelG1 = GUICtrlCreateLabel("Facility:", 8, 112, 46, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG1 = GUICtrlCreateCombo("ComboG1", 80, 112, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Group1 = GUICtrlCreateGroup("Overview", 240, 104, 257, 129)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label1 = GUICtrlCreateLabel("Component Manufacturing Plant 99999999", 248, 128, 241, 19)
	GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
	$Label4 = GUICtrlCreateLabel("System:", 248, 152, 45, 18)
	$Label5 = GUICtrlCreateLabel("Some long system name here.XXX", 304, 152, 185, 18)
	$Label6 = GUICtrlCreateLabel("Planet:", 248, 176, 42, 18)
	$Label7 = GUICtrlCreateLabel("Some long planet name here.XXXX", 303, 176, 189, 18)
	$Label28 = GUICtrlCreateLabel("Sector:", 248, 200, 40, 18)
	$Label29 = GUICtrlCreateLabel("Some long owner such as UUE etc.", 304, 200, 189, 18)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Label2 = GUICtrlCreateLabel("Node Type:", 8, 144, 64, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG2 = GUICtrlCreateCombo("ComboG2", 80, 144, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$ButtonG1 = GUICtrlCreateButton("View Flow Diagram", 8, 208, 115, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label3 = GUICtrlCreateLabel("Produces:", 8, 176, 56, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG3 = GUICtrlCreateCombo("ComboG3", 80, 176, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Label8 = GUICtrlCreateLabel("Industrial Electronics:", 8, 248, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$InputG1 = GUICtrlCreateInput("InputG1", 136, 248, 105, 21)
	$Input1 = GUICtrlCreateInput("InputG1", 136, 272, 105, 21)
	$Label9 = GUICtrlCreateLabel("Industrial Electronics:", 8, 272, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Button1 = GUICtrlCreateButton("Load Live Data", 128, 208, 99, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label10 = GUICtrlCreateLabel("Industrial Electronics:", 8, 296, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input2 = GUICtrlCreateInput("InputG1", 136, 296, 105, 21)
	$Input3 = GUICtrlCreateInput("InputG1", 136, 320, 105, 21)
	$Label11 = GUICtrlCreateLabel("Industrial Electronics:", 8, 320, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label12 = GUICtrlCreateLabel("Industrial Electronics:", 8, 344, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input4 = GUICtrlCreateInput("InputG1", 136, 344, 105, 21)
	$Label13 = GUICtrlCreateLabel("Industrial Electronics:", 264, 248, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input5 = GUICtrlCreateInput("InputG1", 392, 248, 105, 21)
	$Input6 = GUICtrlCreateInput("InputG1", 392, 272, 105, 21)
	$Label14 = GUICtrlCreateLabel("Industrial Electronics:", 264, 272, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label15 = GUICtrlCreateLabel("Industrial Electronics:", 264, 296, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input7 = GUICtrlCreateInput("InputG1", 392, 296, 105, 21)
	$Input8 = GUICtrlCreateInput("InputG1", 392, 320, 105, 21)
	$Label16 = GUICtrlCreateLabel("Industrial Electronics:", 264, 320, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label17 = GUICtrlCreateLabel("Industrial Electronics:", 264, 344, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input9 = GUICtrlCreateInput("InputG1", 392, 344, 105, 21)
	$Label18 = GUICtrlCreateLabel("Industrial Electronics:", 8, 368, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input10 = GUICtrlCreateInput("InputG1", 136, 368, 105, 21)
	$Input11 = GUICtrlCreateInput("InputG1", 136, 392, 105, 21)
	$Label19 = GUICtrlCreateLabel("Industrial Electronics:", 8, 392, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label20 = GUICtrlCreateLabel("Industrial Electronics:", 8, 416, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input12 = GUICtrlCreateInput("InputG1", 136, 416, 105, 21)
	$Input13 = GUICtrlCreateInput("InputG1", 136, 440, 105, 21)
	$Label21 = GUICtrlCreateLabel("Industrial Electronics:", 8, 440, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label22 = GUICtrlCreateLabel("Industrial Electronics:", 8, 464, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input14 = GUICtrlCreateInput("InputG1", 136, 464, 105, 21)
	$Label23 = GUICtrlCreateLabel("Industrial Electronics:", 264, 368, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input15 = GUICtrlCreateInput("InputG1", 392, 368, 105, 21)
	$Input16 = GUICtrlCreateInput("InputG1", 392, 392, 105, 21)
	$Label24 = GUICtrlCreateLabel("Industrial Electronics:", 264, 392, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label25 = GUICtrlCreateLabel("Industrial Electronics:", 264, 416, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input17 = GUICtrlCreateInput("InputG1", 392, 416, 105, 21)
	$Input18 = GUICtrlCreateInput("InputG1", 392, 440, 105, 21)
	$Label26 = GUICtrlCreateLabel("Industrial Electronics:", 264, 440, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label27 = GUICtrlCreateLabel("Industrial Electronics:", 264, 464, 123, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input19 = GUICtrlCreateInput("InputG1", 392, 464, 105, 21)
	$Label30 = GUICtrlCreateLabel("Products produced:", 7, 498, 107, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label31 = GUICtrlCreateLabel("Storage capacity:", 8, 528, 95, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label33 = GUICtrlCreateLabel("99999999", 120, 528, 52, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label34 = GUICtrlCreateLabel("Acceptable", 176, 528, 58, 18)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	GUICtrlSetColor(-1, 0x008000)
	$Button2 = GUICtrlCreateButton("Find Escort Agency", 112, 584, 123, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label35 = GUICtrlCreateLabel("Escorting agency:", 8, 560, 96, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label36 = GUICtrlCreateLabel("Stealth Software Sys.", 120, 560, 117, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label37 = GUICtrlCreateLabel("Most critical component(s):", 250, 500, 152, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label38 = GUICtrlCreateLabel("Industrial Electronics Mk IIX", 336, 520, 156, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label39 = GUICtrlCreateLabel("Industrial Electronics Mk IIX", 336, 536, 156, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Button3 = GUICtrlCreateButton("Export Data for Agency", 256, 584, 123, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button4 = GUICtrlCreateButton("Export Data", 400, 584, 91, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label40 = GUICtrlCreateLabel("Industrial Electronics Mk IIX", 336, 552, 156, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input20 = GUICtrlCreateInput("InputG1", 120, 496, 113, 21)
	GUICtrlSetState(-1, $GUI_DISABLE)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	LoadProductionData()
	; G2 Node Type
	; G3 Production Good

	; 8 Name1
	; InputG1 Num1

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				$iMsgBoxAnswer = MsgBox(292,"Closing Dialog","Are you sure you want to close this dialog?" & @CRLF & "All work will be lost if it wasn't saved.")
				Select
					Case $iMsgBoxAnswer = 6 ;Yes
						GUIDelete($pm_form)
						ExitLoop
					Case $iMsgBoxAnswer = 7 ;No
						; Nothing
				EndSelect
			Case $ComboG1
				GUICtrlSetData($ComboG2, "")
				GUICtrlSetData($ComboG3, "")

				GUICtrlSetData($ComboG2, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "MAIN", "TYPE", ""), IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "MAIN", "TYPE", ""))
				GUICtrlSetData($ComboG3, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", "PROD", ""), IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", "PROD", ""))

				; Area Data
				GUICtrlSetData($Label1, GUICtrlRead($ComboG1))
				GUICtrlSetData($Label5, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "MAIN", "SYS", ""))
				GUICtrlSetData($Label7, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "MAIN", "PLAN", ""))
				GUICtrlSetData($Label29, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "MAIN", "SECT", ""))

				; Buttons
				If FileExists("data\flow diagrams\"&GUICtrlRead($ComboG3)&"\data.jpg") Then
					GUICtrlSetState($ButtonG1, $GUI_ENABLE)
				EndIf


				; 1
				FillProductionData($Label8, $InputG1, 1)
				FillProductionData($Label9, $Input1, 2)
				FillProductionData($Label10, $Input2, 3)
				FillProductionData($Label11, $Input3, 4)
				FillProductionData($Label12, $Input4, 5)
				FillProductionData($Label18, $Input10, 6)
				FillProductionData($Label19, $Input11, 7) ; 1911? :O
				FillProductionData($Label20, $Input12, 8) ; 2012? :O
				FillProductionData($Label21, $Input13, 9)
				;FillProductionData($Label22, $Input14, 10) ; Something witty here about 1914
				;FillProductionData($Label13, $Input5, 11)
			Case $ButtonG1
				ShellExecute("data\flow diagrams\"&GUICtrlRead($ComboG3)&"\data.jpg")
			Case $LabelG2
				OpenUrl("http://code.google.com/p/star-datapad/wiki/ProductionManager")
		EndSwitch
	WEnd
EndFunc

Func FillProductionData($LabelNameA, $LabelNameB, $NUM)
	Local $guiread

	; --------------------------------------------------------------------------------------------------------------
	; Load data

	; Check to see if the quantity even exits!
	If IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM, "") = "" Then
		GUICtrlSetData($LabelNameA, " - ")
		GUICtrlSetData($LabelNameB, "")
		ConsoleWrite("Returning 0 as data for "&$NUM&" wasn't found."&@CRLF)
		Return(0)
	EndIf

	; Set the title of the quantity
	GUICtrlSetData($LabelNameA, IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM, "")&":")

	; Now to check if we have to do any calculations...
	$numberof = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM&"NUM", "0")

	; --------------------------------------------------------------------------------------------------------------

	If $numberof <> 0 Then
		; We have a stack of something, and doesn't need need calculating.
		ConsoleWrite("Resource "&$NUM&" is a stack of something. It equals "&$numberof&@CRLF)
		GUICtrlSetData($LabelNameB, $numberof)
		ConsoleWrite("--------"&@CRLF)

	Else
		; We are dealing with something that requires other things to work off of.
		ConsoleWrite("Resource "&$NUM&" requires calculations."&@CRLF)

		; Figure out number of resources X is dependent on
		$requirements = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM&"REQ", "0")


		$eachrequirement = StringSplit($requirements, ",")

		$firstloop = True

		; Get the number of requirements for flagging changes.
		$REQDATA[0] = $eachrequirement[0]

		ConsoleWrite("Resource "&$NUM&" is dependent on "&$eachrequirement[0]&" resource(s)."&@CRLF)

		; Setup an array which will store duplicate changes
		Local $isprocessed[9999]
		;ConsoleWrite("Setting up $savinggrace array to track "&30&" resource(s)."&@CRLF)

		; Figure out how many tier-2 resources also share this same dependent resource

		; So what happens when we have several resources requiring the same thing?
		; We will evenly divide the resources among how many there are. Shove the unused shares back to where they belong in the GUI.
		; This will have to be changed some time.

		; As the current system stands, we see if the value got changed before. If it hasn't, split the value then.

		For $i = 1 To $eachrequirement[0]



			If $isprocessed[$eachrequirement[$i]] = True Then

				MsgBox(0, "", "This resource ("&$eachrequirement[$i]&") was already processed.")

				; Wait a second, there's something already stored in there!
				;MsgBox(0, "!", "Something was already stored in the array! "&$NUM&": "&$lowestvaluereq[$NUM])
				;ConsoleWrite("Something was already stored in the array! "&$NUM&": "&$lowestvaluereq[$NUM]&@CRLF)

				; Probably not the best idea, but this works.
				;$savinggrace[$eachrequirement[$i]] = $lowestvaluereq[$NUM]
				;ConsoleWrite("$savinggrace "&$savinggrace[$eachrequirement[$i]]&": "&$lowestvaluereq[$NUM]&@CRLF)
			EndIf

			ConsoleWrite("Checking "&$eachrequirement[$i]&" for modification flag."&@CRLF)
			If CheckRequirementDataChanged($eachrequirement[$i]) = True Then
				$valueA = GUICtrlRead(LookupHandle($eachrequirement[$i]))

				ConsoleWrite("The requirement "& $eachrequirement[$i] & " data has been modified since the last time. Passing gui display value of "&$valueA&@CRLF)

				ConsoleWrite("The previous C value (a.k.a fair share) was = "&$previousCValue[$eachrequirement[$i]]&@CRLF)

				; Bad! I found yet another GUISet function that needs to be moved out!
				GUICtrlSetData(LookupHandle($eachrequirement[$i]), $valueA - $previousCValue[$eachrequirement[$i]])
				ConsoleWrite($previousCValue[$eachrequirement[$i]]&" has been subtracted from "&$eachrequirement[$i]&" resource stockpile. The result is now "&$valueA - $previousCValue[$eachrequirement[$i]]&@CRLF)
				; UPDATE HERE _______________________________________________

				; Serious issue spotted.
				; So we have changed the resource in the gui, but the array needs an update!
				ConsoleWrite("Updating value for resource "&$eachrequirement[$i]&" to "&$valueA - $previousCValue[$eachrequirement[$i]]&@CRLF)
				$lowestvaluereq[$eachrequirement[$i]] = $valueA - $previousCValue[$eachrequirement[$i]]

				; Figure out how much the calling resource needs
				$valueNeeded = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM&"NED"&$eachrequirement[$i], "")
				ConsoleWrite("The dependent resource " & $eachrequirement[$i] & " has " & $valueA & " units. Demanding resource " & $NUM & " has a ratio of 1:" & $valueNeeded & ". There are " & $eachrequirement[0] - 1 & " other dependent resource(s)." & @CRLF)

				$convertedvalue = $previousCValue[$eachrequirement[$i]]/$valueNeeded
				ConsoleWrite("The converstion has resulted in "&$convertedvalue&" of the new resource. The value in the gui is now "&$valueA - $previousCValue[$eachrequirement[$i]]&@CRLF)

				; We don't write the value to the gui yet! What happens if this isn't the least producting resource?
				;GUICtrlSetData($LabelNameB, Floor($convertedvalue))

				; Store the value of the requirement
				; Here we want to check if the converted value changes twice!
				$lowestvaluereq[$NUM] = $convertedvalue
				_ArrayDisplay($lowestvaluereq)
				ConsoleWrite("$lowestvaluereq[$NUM] = ["&$NUM&"] & "&$convertedvalue&@CRLF)

				;If $eachrequirement[0] >= 2 Then
				;	$savinggrace[$eachrequirement[$i]] = $convertedvalue
				;	_ArrayDisplay($savinggrace)
				;EndIf

			Else
				ConsoleWrite($eachrequirement[$i]&" isn't flagged for modification."&@CRLF)

				$valueA = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $eachrequirement[$i]&"NUM", -1)
				If $valueA = -1 Then
					; Well the ini doesn't have the info. Maybe the gui input has it?
					$read = GUICtrlRead(LookupHandle($eachrequirement[$i]))
					If $read = 0 Then
						; Something failed. This isn't looking good at all!
						MsgBox(0, "Error", "Something went really wrong. The ini value for "&$eachrequirement[$i]&"NUM"&" could not be found! As well, the GUI value couldn't be found!")
					Else
						$valueA = $read
						$guiread = True
					EndIf
				EndIf

				; Grab how many resources share this..
				$shares = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $eachrequirement[$i]&"SHARE", 0)
				ConsoleWrite($eachrequirement[$i]&" is shared among "&$shares&" resource(s)."&@CRLF)

				; Figure out how much the calling resource needs
				$valueNeeded = IniRead("data\facilities\"&GUICtrlRead($ComboG1)&"\data.ini", "NEEDS", $NUM&"NED"&$eachrequirement[$i], "")
				ConsoleWrite("The dependent resource " & $eachrequirement[$i] & " has " & $valueA & " units. Resource " & $NUM & " has a ratio of 1:" & $valueNeeded & ". There are " & $eachrequirement[0] - 1 & " other dependent resource(s)." & @CRLF)

				; So now we know how many are sharing this resource, and how much we need, start doing the math!

				; Since we are sharing with Y number, we want to take an even share and throw the rest back into the gui.
				; This will have to be changed some time. Maybe based on some market worth of the resource?

				If $shares = 0 Then
					; If we are somehow not sharing at this stage, someone buggered on the data entry. :)
					$valueC = $valueA
					MsgBox(0, "Error", "The file defines a share of 0. This isn't correct!")
				Else
					; Round down to make sure things stay
					$valueC = Floor($valueA/$shares)
				EndIf

				; We have been given $valueC to work with.
				ConsoleWrite($valueC&" has been allocated of "&$eachrequirement[$i]&" resource."&@CRLF)

				; But first, subtract what we used from the stack. Woah, kind of rymes doesn't it?
				; Figure out which control houses the data for that resource with LookupHandle()

				; If we used the GUI to get the data, double check what was in there!
				If $guiread = True Then
					GUICtrlSetData(LookupHandle($eachrequirement[$i]), GUICtrlRead(LookupHandle($eachrequirement[$i])) - $valueC)
					ConsoleWrite("[True] "&$valueC&" has been subtracted from "&$eachrequirement[$i]&" resource stockpile. The result is now '"&GUICtrlRead(LookupHandle($eachrequirement[$i]))&"'."&@CRLF)

					; Serious issue spotted.
					; So we have changed the resource in the gui, but the array needs an update!
					ConsoleWrite("Updating value for resource "&$eachrequirement[$i]&" to "&GUICtrlRead(LookupHandle($eachrequirement[$i]))&@CRLF)
					$lowestvaluereq[$eachrequirement[$i]] = GUICtrlRead(LookupHandle($eachrequirement[$i]))


					; Now due the converstion, how many X equals Y?
					; $valueNeeded is from up above. ^ ^ ^ ^ ^

					$convertedvalue = Floor($valueC/$valueNeeded)

					ConsoleWrite("The converstion has resulted in "&$convertedvalue&" of the new resource. The value in the gui is now '"&GUICtrlRead(LookupHandle($eachrequirement[$i]))&"'."&@CRLF)

					; Now write the converted value to it's correct location.
					; $LabelNameB was passed as an argument to the function.
					; We don't write the value to the gui yet! What happens if this isn't the least producting resource?
					;GUICtrlSetData($LabelNameB, $convertedvalue)
					$previousCValue[$eachrequirement[$i]] = $valueC
				Else
					GUICtrlSetData(LookupHandle($eachrequirement[$i]), GUICtrlRead(LookupHandle($eachrequirement[$i])) - $valueC)
					ConsoleWrite("[False] "&$valueC&" has been subtracted from "&$eachrequirement[$i]&" resource stockpile. The value in the gui is now '"&GUICtrlRead(LookupHandle($eachrequirement[$i]))&"'."&@CRLF)

					; Now due the converstion, how many X equals Y?
					; $valueNeeded is from up above. ^ ^ ^ ^ ^

					$convertedvalue = Floor($valueC/$valueNeeded)

					ConsoleWrite("The converstion has resulted in "&$convertedvalue&" of the new resource "&$NUM&". Storing into handle "&$LabelNameB&@CRLF)

					; Now write the converted value to it's correct location.
					; $LabelNameB was passed as an argument to the function.
					; We don't write the value to the gui yet! What happens if this isn't the least producting resource?
					; GUICtrlSetData($LabelNameB, $convertedvalue)
					$previousCValue[$eachrequirement[$i]] = $valueC
				EndIf

				; Store the value of the requirement
				$lowestvaluereq[$NUM] = $convertedvalue
				ConsoleWrite("$lowestvaluereq[$NUM] = ["&$NUM&"] & "&$convertedvalue&@CRLF)

				RequirementDataChanged($eachrequirement[$i])
				ConsoleWrite("$REQDATA[$eachrequirement[$i]] = "&$REQDATA[$eachrequirement[$i]]&""&@CRLF)

			EndIf

		Next

		; Now what happens when we have a 2nd, 3rd, 4th.. requirement?
		; Well.. We have to find the lowest value to do anything after some division.
		; Then we determine which was the lowest, resulting in how many of the demanding product
		; And finaly give back the unused portions to the other requirements (in their GUI inputs)

		_ArrayDisplay($isprocessed)

		ConsoleWrite("[X] Resource "&$NUM&" is dependent on "&$eachrequirement[0]&" resource(s)."&@CRLF)

		;If CheckRequirementDataChanged($eachrequirement[$i]) = True Then
		;	GUICtrlSetData(LookupHandle($eachrequirement[$i]), $valueA - $previousCValue[$eachrequirement[$i]])


		; Noes! We have some math to work out :(
		ConsoleWrite("Noes! We have some math to work out :("&@CRLF)

		; What were those dependent resource numbers again?

		; To make counting easy, store into a 2D array like so $array[i] = [$eachrequirement[$x]][$lowestvaluereq[$eachrequirement[$x]]]

		; Initialize values so we can compare
		$lowestvalue = 0
		$lowestvaluecamefrom = 0

		$firsttime = True

		For $x = 1 To $eachrequirement[0]
			ConsoleWrite("[X] One of those dependent resources is "&$eachrequirement[$x]&"."&@CRLF)
			ConsoleWrite("[X] It's value in the array is "&$lowestvaluereq[$eachrequirement[$x]]&"."&@CRLF)

			;If $lowestvaluereq[$eachrequirement[$x]] = 0 Then
				; Reverse the last operation, as we need that value

			If $firsttime = True Then
				; Well.. The first time we are in here, we should have the lowest value!
				$lowestvalue = $lowestvaluereq[$eachrequirement[$x]]
				$firsttime = False
				$lowestvaluecamefrom = $eachrequirement[$x]
			Else
				; If it isn't the first time through, compare
				If $lowestvaluereq[$eachrequirement[$x]] < $lowestvalue Then
					; We have a new smallest value!
					$lowestvalue = $lowestvaluereq[$eachrequirement[$x]]
					$lowestvaluecamefrom = $eachrequirement[$x]
				EndIf
			EndIf
		Next

		ConsoleWrite("[X] The smallest value is from  "&$lowestvaluecamefrom&". It holds a value of "&$lowestvalue&"."&@CRLF)

		;$lowestvaluereq[$NUM]

		GUICtrlSetData($LabelNameB, $convertedvalue)

		_ArrayDisplay($lowestvaluereq)

		;
		;$lowestvaluereq[$eachrequirement[$i]] = $convertedvalue
		;
		; So there's $convertedvalue of resource


		#cs
		If ($valueC/$valueNeeded > $lowestvalue) And ($firstloop = True) Then
			; So the first time around, we should have the lowest value.
			$lowestvalue = $valueC/$valueNeeded
			$lowestvaluereq = $eachrequirement[$i]
			$firstloop = False
		Else
			; If the first one doesn't happen to have the lowest value, change it.
			If ($valueC/$valueNeeded < $lowestvalue) Then
				$lowestvalue = $valueC/$valueNeeded
				$lowestvaluereq = $eachrequirement[$i]
			EndIf
		EndIf
		#ce
		ConsoleWrite("========================================="&@CRLF)
	EndIf

EndFunc

Func RequirementDataChanged($PASSEDNUM)
	$REQDATA[$PASSEDNUM] = True
EndFunc

Func CheckRequirementDataChanged($PASSEDNUM)
	If $REQDATA[$PASSEDNUM] = True Then
		Return True
	Else
		Return False
	EndIf
EndFunc

Func LookupHandle($inputvalue)
	Switch $inputvalue
		; We have to look up the handle of the label for the resource we need to change.
		Case 1
			$handle = $InputG1
		Case 2
			$handle = $Input1
		Case 3
			$handle = $Input2
		Case 4
			$handle = $Input3
		Case 5
			$handle = $Input4
		Case 6
			$handle = $Input10
		Case 7
			$handle = $Input11
			; 7-11 :O Magic!
		Case 8
			$handle = $Input12
		Case 9
			$handle = $Input13
		Case 10
			$handle = $Input14
		Case 11
			$handle = $Input5
	EndSwitch

	Return $handle

EndFunc

Func LoadProductionData()
	; Read ships in data folder
	$FileList = _FileListToArray("data\facilities\", "*", 2)
	If $FileList = 0 Then
		MsgBox(0, "E", "ERROR "&@error)
	EndIf

	$folders = ""

	For $i = 1 to $FileList[0]
		;MsgBox(0, "E", $i&" "&$FileList[$i])
		$folders = $folders&"|"&$FileList[$i]
	Next

	GUICtrlSetData($ComboG1, $folders)
EndFunc

Func ShipDB()
	#Region ### START Koda GUI section ### Form=
	$Main = GUICreate("Ship DB (SDB) - Citizen Datapad", 701, 689, -1, -1)
	$MenuItem1 = GUICtrlCreateMenu("&File")
	$MenuItem3 = GUICtrlCreateMenuItem("About", $MenuItem1)
	$MenuItem4 = GUICtrlCreateMenuItem("Close", $MenuItem1)
	$MenuItem2 = GUICtrlCreateMenu("&Ships")
	$MenuItem5 = GUICtrlCreateMenuItem("Load Data", $MenuItem2)
	$MenuItem6 = GUICtrlCreateMenuItem("Open Data Folder", $MenuItem2)
	$Label1 = GUICtrlCreateLabel("Ship:", 8, 8, 31, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Combo1 = GUICtrlCreateCombo("Combo1", 40, 8, 217, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Pic1 = GUICtrlCreatePic("", 264, 0, 436, 256)
	$Group1 = GUICtrlCreateGroup("General Information", 8, 32, 249, 73)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label5 = GUICtrlCreateLabel("Role:", 16, 80, 32, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label6 = GUICtrlCreateLabel("XXXXXXXXXXXXXXXXXXXXXXXX", 104, 80, 148, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label8 = GUICtrlCreateLabel("Manufacturer:", 16, 56, 80, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label4 = GUICtrlCreateLabel("XXXXXXXXXXXXXXXXXXXXXXXX", 104, 56, 148, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Group2 = GUICtrlCreateGroup("Measurements", 8, 112, 249, 73)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label2 = GUICtrlCreateLabel("Beam:", 16, 160, 38, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label3 = GUICtrlCreateLabel("XXXXXXXXX", 64, 160, 58, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label7 = GUICtrlCreateLabel("Length:", 16, 136, 43, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label9 = GUICtrlCreateLabel("XXXXXXXXX", 64, 136, 58, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label10 = GUICtrlCreateLabel("XXXXXXXXX", 192, 136, 58, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label11 = GUICtrlCreateLabel("Height:", 144, 136, 43, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label12 = GUICtrlCreateLabel("XXXXXXXXX", 192, 160, 58, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label13 = GUICtrlCreateLabel("Mass:", 144, 160, 36, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Group3 = GUICtrlCreateGroup("Structure", 8, 192, 249, 73)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label14 = GUICtrlCreateLabel("Crew:", 16, 240, 33, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label15 = GUICtrlCreateLabel("99 person(s)", 48, 240, 71, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label16 = GUICtrlCreateLabel("Cargo Capacity:", 16, 216, 85, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label17 = GUICtrlCreateLabel("9999 tonnes", 104, 216, 69, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label20 = GUICtrlCreateLabel("99 slots", 208, 240, 46, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label21 = GUICtrlCreateLabel("Upg. Space:", 136, 240, 66, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Group4 = GUICtrlCreateGroup("Power/Propulsion", 8, 272, 345, 121)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label18 = GUICtrlCreateLabel("Ace Astrogation FusionPro 3H III", 168, 296, 178, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label19 = GUICtrlCreateLabel("Max. Engine(s):", 16, 320, 86, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label22 = GUICtrlCreateLabel("Power Plant Size:", 16, 296, 96, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label23 = GUICtrlCreateLabel("99", 112, 296, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label24 = GUICtrlCreateLabel("TR5", 136, 320, 23, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label25 = GUICtrlCreateLabel("99", 112, 320, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label26 = GUICtrlCreateLabel("Hammer Propulsion HM 4.4 (TR4)", 168, 320, 181, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label27 = GUICtrlCreateLabel("Thrusters (1):", 16, 344, 75, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label28 = GUICtrlCreateLabel("99", 112, 344, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label29 = GUICtrlCreateLabel("TR5", 136, 344, 23, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label30 = GUICtrlCreateLabel("Hammer Propulsion HM 4.4 (TR4)", 168, 344, 181, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label31 = GUICtrlCreateLabel("Thrusters (2):", 16, 368, 75, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label32 = GUICtrlCreateLabel("99", 112, 368, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label33 = GUICtrlCreateLabel("TR5", 136, 368, 23, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label34 = GUICtrlCreateLabel("Hammer Propulsion HM 4.4 (TR4)", 168, 368, 181, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Button1 = GUICtrlCreateButton("View BluePrint", 360, 264, 83, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button2 = GUICtrlCreateButton("3D View", 448, 264, 75, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button3 = GUICtrlCreateButton("Scale Diagram", 528, 264, 75, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button4 = GUICtrlCreateButton("Button4", 616, 264, 75, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Group5 = GUICtrlCreateGroup("Hardpoints", 360, 296, 337, 369)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label35 = GUICtrlCreateLabel("Cass-2:", 368, 360, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label37 = GUICtrlCreateLabel("Class-1:", 368, 320, 46, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label36 = GUICtrlCreateLabel("99", 416, 320, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label38 = GUICtrlCreateLabel("99", 416, 336, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label39 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 320, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label40 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 336, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label41 = GUICtrlCreateLabel("99", 416, 360, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label42 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 360, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label43 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 376, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label44 = GUICtrlCreateLabel("99", 416, 376, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label45 = GUICtrlCreateLabel("Cass-3:", 368, 400, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label46 = GUICtrlCreateLabel("99", 416, 400, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label47 = GUICtrlCreateLabel("99", 416, 416, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label48 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 400, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label49 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 416, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label50 = GUICtrlCreateLabel("Cass-4:", 368, 440, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label51 = GUICtrlCreateLabel("99", 416, 440, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label52 = GUICtrlCreateLabel("99", 416, 456, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label53 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 440, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label54 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 456, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label55 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 480, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label56 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 496, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label57 = GUICtrlCreateLabel("99", 416, 496, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label58 = GUICtrlCreateLabel("99", 416, 480, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label59 = GUICtrlCreateLabel("Cass-5:", 368, 480, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label60 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 520, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label61 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 536, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label62 = GUICtrlCreateLabel("99", 416, 536, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label63 = GUICtrlCreateLabel("99", 416, 520, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label64 = GUICtrlCreateLabel("Cass-6:", 368, 520, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label65 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 560, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label66 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 576, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label67 = GUICtrlCreateLabel("99", 416, 576, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label68 = GUICtrlCreateLabel("99", 416, 560, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label69 = GUICtrlCreateLabel("Cass-7:", 368, 560, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label70 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 600, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label71 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 616, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label72 = GUICtrlCreateLabel("99", 416, 616, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label73 = GUICtrlCreateLabel("99", 416, 600, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label74 = GUICtrlCreateLabel("Cass-8:", 368, 600, 42, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label75 = GUICtrlCreateLabel("KnightBridge Arms 9-Series Longsword (nose)", 440, 640, 249, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label78 = GUICtrlCreateLabel("99", 416, 640, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label79 = GUICtrlCreateLabel("Add. Eq:", 368, 640, 47, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Group6 = GUICtrlCreateGroup("Shield Data", 8, 400, 345, 65)
	GUICtrlSetFont(-1, 9, 800, 0, "Calibri")
	$Label76 = GUICtrlCreateLabel("Ace Astrogation FusionPro 3H III Ace Astrogation FusionPro 3H III", 112, 424, 235, 34)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label80 = GUICtrlCreateLabel("Max Shield:", 16, 424, 67, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label81 = GUICtrlCreateLabel("99", 88, 424, 16, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	LoadShipData()

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Main)
				ExitLoop
			Case $Combo1

				; Check for files to enable buttons

				; First up is the blueprint..
				If FileExists("data\ships\"&GUICtrlRead($Combo1)&"\blueprint.jpg") = 1 Then
					GUICtrlSetState($Button1, $GUI_ENABLE)
				Else
					GUICtrlSetState($Button1, $GUI_DISABLE)
				EndIf

				; Second up is a check for the "3D View"
				If FileExists("data\ships\"&GUICtrlRead($Combo1)&"\3D View\1.jpg") = 1 Then
					GUICtrlSetState($Button2, $GUI_ENABLE)
				Else
					GUICtrlSetState($Button2, $GUI_DISABLE)
				EndIf

				; Last up is a check for the scale diagram
				If FileExists("data\ships\"&GUICtrlRead($Combo1)&"\scalediagram.jpg") = 1 Then
					GUICtrlSetState($Button3, $GUI_ENABLE)
				Else
					GUICtrlSetState($Button3, $GUI_DISABLE)
				EndIf

				; Data in GUI
				;
				; $Label6 is role
				; $Label4 is manfac

				; label3 is beam
				; label9 is length
				; label12 is mass
				; label10 is height

				; label17 is capacity
				; 15 is crew
				; 20 is upg. slots

				; 23 power size
				; 18 name
				; 25 engine num
				; 24 engine type
				; 26 engine name
				; 28 thrust1 num
				; 29 thrust1 type
				; 30 thrust1 name
				; 32 thrust2 num
				; 33 thrust2 type
				; 24 thrust2 name


				; Picture(s)
				GUICtrlSetImage($Pic1, "data\ships\"&GUICtrlRead($Combo1)&"\image.jpg")

				; General Info
				GUICtrlSetData($Label4, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MAIN", "MAN", "Error"))
				GUICtrlSetData($Label6, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MAIN", "ROLE", "Error"))

				; Measurements
				GUICtrlSetData($Label3, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MEAS", "BEAM", "Error") & "m")
				GUICtrlSetData($Label9, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MEAS", "LENG", "Error") & "m")
				GUICtrlSetData($Label12, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MEAS", "MASS", "Error") & "kg")
				GUICtrlSetData($Label10, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "MEAS", "HEIG", "Error") & "m")

				; Structure
				GUICtrlSetData($Label17, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "CAPA", "Error") & " tonnes")
				GUICtrlSetData($Label15, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "CREW", "Error") & " person(s)")
				GUICtrlSetData($Label20, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "SPAC", "Error") & " slots")

				; Power
				GUICtrlSetData($Label23, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "POWR", "00"))
				GUICtrlSetData($Label18, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "FPWR", "Error"))

				GUICtrlSetData($Label25, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "ENUM", "00"))
				GUICtrlSetData($Label24, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "ENGI", "Error"))
				GUICtrlSetData($Label26, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "FENG", "Error"))

				GUICtrlSetData($Label28, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "TNUM", "00"))
				GUICtrlSetData($Label29, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "THRU", "Error"))
				GUICtrlSetData($Label30, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "FTHR", "Error"))

				GUICtrlSetData($Label32, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "TNU2", "00"))
				GUICtrlSetData($Label33, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "THR2", " - "))
				GUICtrlSetData($Label34, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "FTH2", " - "))

				; Shield
				GUICtrlSetData($Label81, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "SHIL", "00"))
				GUICtrlSetData($Label76, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "STRU", "FSHI", " - "))

				; Hardpoints (oh boy! The best part!)

				GUICtrlSetData($Label36, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C1", "00"))
				GUICtrlSetData($Label39, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C1IN", ""))
				GUICtrlSetData($Label38, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C1a", ""))
				GUICtrlSetData($Label40, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C1Ia", ""))

				GUICtrlSetData($Label41, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C2", "00"))
				GUICtrlSetData($Label42, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C2I", ""))
				GUICtrlSetData($Label44, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C2a", ""))
				GUICtrlSetData($Label43, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C2Ia", ""))

				GUICtrlSetData($Label46, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C3", "00"))
				GUICtrlSetData($Label48, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C3I", ""))
				GUICtrlSetData($Label47, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C3a", ""))
				GUICtrlSetData($Label49, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C3Ia", ""))

				GUICtrlSetData($Label51, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C4", "00"))
				GUICtrlSetData($Label53, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C4I", ""))
				GUICtrlSetData($Label52, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C4a", ""))
				GUICtrlSetData($Label54, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C4Ia", ""))

				GUICtrlSetData($Label58, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C5", "00"))
				GUICtrlSetData($Label55, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C5I", ""))
				GUICtrlSetData($Label57, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C5a", ""))
				GUICtrlSetData($Label56, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C5Ia", ""))

				GUICtrlSetData($Label63, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C6", "00"))
				GUICtrlSetData($Label60, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C6I", ""))
				GUICtrlSetData($Label62, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C6a", ""))
				GUICtrlSetData($Label61, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C6Ia", ""))

				GUICtrlSetData($Label68, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7", "00"))
				GUICtrlSetData($Label65, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7I", ""))
				GUICtrlSetData($Label67, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7a", ""))
				GUICtrlSetData($Label66, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7Ia", ""))

				GUICtrlSetData($Label73, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7", "00"))
				GUICtrlSetData($Label70, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7I", ""))
				GUICtrlSetData($Label72, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7a", ""))
				GUICtrlSetData($Label71, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "C7Ia", ""))

				GUICtrlSetData($Label78, "01")
				GUICtrlSetData($Label75, IniRead("data\ships\"&GUICtrlRead($Combo1)&"\data.ini", "HARD", "ADDE", ""))

			Case $MenuItem5
				LoadShipData()
			Case $Button1
				BluePrint()
			Case $Button3
				ScaleDiagram()
			Case $Button2
				ThreeDView(GUICtrlRead($Combo1))
			Case $MenuItem4
				GUIDelete($Main)
				ExitLoop
			Case $MenuItem3
				AboutDialog()
			Case $MenuItem6
				; Open folder with ship data
		EndSwitch
	WEnd
EndFunc

Func LoadShipData()
	; Read ships in data folder
	$FileList = _FileListToArray("data\ships\", "*", 2)
	If $FileList = 0 Then
		MsgBox(0, "E", "ERROR "&@error)
	EndIf

	$folders = ""

	For $i = 1 to $FileList[0]
		;MsgBox(0, "E", $i&" "&$FileList[$i])
		$folders = $folders&"|"&$FileList[$i]
	Next

	GUICtrlSetData($Combo1, $folders)
EndFunc

Func Prospector()
	#Region ### START Koda GUI section ### Form=
	$mp_form = GUICreate("Mining Prospector (MP)", 501, 527, -1, -1)
	$Pic1 = GUICtrlCreatePic("data\launch\ore_header.jpg", 0, 0, 500, 100)
	$LabelG2 = GUICtrlCreateLabel("Help Manual Link", 8, 504, 88, 18)
	GUICtrlSetFont(-1, 9, 400, 2, "Calibri")
	GUICtrlSetColor(-1, 0x0000FF)
	GUICtrlSetCursor (-1, 0)
	$LabelG1 = GUICtrlCreateLabel("Sector:", 8, 152, 40, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG1 = GUICtrlCreateCombo("ComboG1", 80, 152, 137, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Group1 = GUICtrlCreateGroup("Overview", 224, 104, 273, 217)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label1 = GUICtrlCreateLabel("Survey Agency Name X", 232, 120, 129, 19)
	GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
	$Label4 = GUICtrlCreateLabel("Employees:", 232, 144, 66, 18)
	$Label5 = GUICtrlCreateLabel("9999999", 312, 144, 46, 18)
	$Label6 = GUICtrlCreateLabel("Trust Level:", 232, 168, 65, 18)
	$Pic2 = GUICtrlCreatePic("", 360, 120, 128, 128)
	$Label15 = GUICtrlCreateLabel("XXXXXXX", 312, 168, 46, 18)
	$Label7 = GUICtrlCreateLabel("Extranet Site Link", 397, 291, 93, 19)
	GUICtrlSetFont(-1, 10, 400, 2, "Calibri Light")
	GUICtrlSetColor(-1, 0x0000FF)
	$Label16 = GUICtrlCreateLabel('"We excel at some form of great excellence XX"', 231, 258, 259, 18)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Label2 = GUICtrlCreateLabel("System:", 8, 184, 45, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG2 = GUICtrlCreateCombo("ComboG2", 80, 184, 137, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$ButtonG1 = GUICtrlCreateButton("Load Survey Data", 8, 112, 99, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label3 = GUICtrlCreateLabel("Field/Area:", 8, 216, 65, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$ComboG3 = GUICtrlCreateCombo("ComboG3", 80, 216, 137, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Button1 = GUICtrlCreateButton("Prepare Data", 112, 112, 99, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button2 = GUICtrlCreateButton("Find Survey Agency", 112, 496, 123, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Button4 = GUICtrlCreateButton("Export Data", 400, 496, 91, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	$Label8 = GUICtrlCreateLabel("Asteroid Count:", 8, 256, 87, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input1 = GUICtrlCreateInput("Input1", 104, 256, 113, 21)
	$Label9 = GUICtrlCreateLabel("Tiny:", 8, 288, 29, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input2 = GUICtrlCreateInput("Input1", 104, 288, 113, 21)
	$Label10 = GUICtrlCreateLabel("Small:", 8, 312, 38, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input3 = GUICtrlCreateInput("Input1", 104, 312, 113, 21)
	$Label11 = GUICtrlCreateLabel("Medium:", 8, 336, 52, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input4 = GUICtrlCreateInput("Input1", 104, 336, 113, 21)
	$Label12 = GUICtrlCreateLabel("Large:", 8, 360, 36, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input5 = GUICtrlCreateInput("Input1", 104, 360, 113, 21)
	$Label13 = GUICtrlCreateLabel("Huge:", 8, 384, 35, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input6 = GUICtrlCreateInput("Input1", 104, 384, 113, 21)
	$Group2 = GUICtrlCreateGroup("Ore Overview", 224, 328, 273, 153)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Label17 = GUICtrlCreateLabel("Some Long Rare Ore X", 232, 344, 126, 19)
	GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
	$Label18 = GUICtrlCreateLabel("Rarity:", 232, 368, 38, 18)
	$Label19 = GUICtrlCreateLabel("XXXXXXXXXXXX", 280, 368, 76, 18)
	$Label20 = GUICtrlCreateLabel("Mass:", 232, 392, 36, 18)
	$Pic3 = GUICtrlCreatePic("", 360, 344, 128, 128)
	$Label21 = GUICtrlCreateLabel("999999999 kg", 280, 392, 73, 18)
	$Label22 = GUICtrlCreateLabel("Extranet Site Link", 264, 456, 93, 19)
	GUICtrlSetFont(-1, 10, 400, 2, "Calibri Light")
	GUICtrlSetColor(-1, 0x0000FF)
	$Label24 = GUICtrlCreateLabel("99999 kg", 304, 416, 49, 18)
	$Label25 = GUICtrlCreateLabel("Proc. Mass:", 232, 416, 64, 18)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$Label14 = GUICtrlCreateLabel("Visable Ores:", 8, 416, 77, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Combo4 = GUICtrlCreateCombo("ComboG4", 88, 416, 129, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
	$Label26 = GUICtrlCreateLabel("Estimated Value:", 8, 456, 97, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	$Input7 = GUICtrlCreateInput("Input1", 104, 456, 113, 21)
	$Button3 = GUICtrlCreateButton("Check Star Map", 264, 496, 107, 25)
	GUICtrlSetState(-1, $GUI_DISABLE)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($mp_form)
				ExitLoop

		EndSwitch
	WEnd

EndFunc

Func BluePrint()
	#Region ### START Koda GUI section ### Form=
	$Form2 = GUICreate("BluePrint Dialog", 1232, 841, 202, 58)
	GUISetBkColor(0x000000)
	$ButtonX = GUICtrlCreateButton("&Close", 560, 808, 131, 25)
	$PicX = GUICtrlCreatePic("data\ships\"&GUICtrlRead($Combo1)&"\blueprint.jpg", 0, 0, 1231, 803)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Form2)
				ExitLoop
			Case $ButtonX
				GUIDelete($Form2)
				ExitLoop
		EndSwitch
	WEnd
EndFunc

Func ScaleDiagram()
	#Region ### START Koda GUI section ### Form=
	$Form4 = GUICreate("Scale Diagram Dialog", 1232, 841, 202, 58)
	GUISetBkColor(0xFFFFFF)
	$ButtonY = GUICtrlCreateButton("&Close", 560, 808, 131, 25)
	$PicY = GUICtrlCreatePic("data\ships\"&GUICtrlRead($Combo1)&"\scalediagram.jpg", 0, 0, 1231, 803)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Form4)
				ExitLoop
			Case $ButtonY
				GUIDelete($Form4)
				ExitLoop
		EndSwitch
	WEnd
EndFunc

Func ThreeDView($ship)

	$Form2 = GUICreate("Form2", 1029, 586, 192, 126)
	$PicF3 = GUICtrlCreatePic("data\ships\"&$ship&"\3D View\"&$files[1], 0, 0, 1028, 540)
	$ButtonF1 = GUICtrlCreateButton("<-- Previous", 368, 544, 131, 33)
	$ButtonF2 = GUICtrlCreateButton("Next -->", 536, 544, 131, 33)
	GUISetState(@SW_SHOW)

	GUICtrlSetState($ButtonF1, $GUI_DISABLE)

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Form2)
				ExitLoop
			Case $ButtonF1
				$count = $count - 1
				$test = GUICtrlSetImage($PicF3, "data\ships\"&$ship&"\3D View\"&$count&".jpg")
				Check()
			Case $ButtonF2
				$count = $count + 1
				$test = GUICtrlSetImage($PicF3, "data\ships\"&$ship&"\3D View\"&$count&".jpg")
				Check()
		EndSwitch
	WEnd
EndFunc

Func gui1disable()
	GUICtrlSetState($Checkbox1, $GUI_DISABLE)
	GUICtrlSetState($Checkbox2, $GUI_DISABLE)
	GUICtrlSetState($Checkbox3, $GUI_DISABLE)
	GUICtrlSetState($Checkbox4, $GUI_DISABLE)
	GUICtrlSetState($Checkbox6, $GUI_DISABLE)
	GUICtrlSetState($ComboX1, $GUI_DISABLE)
	GUICtrlSetState($ButtonA4, $GUI_DISABLE)
	GUICtrlSetState($ButtonA1, $GUI_DISABLE)

	GUICtrlSetState($InputX9, $GUI_DISABLE)
	GUICtrlSetState($InputX10, $GUI_DISABLE)
	GUICtrlSetState($InputX11, $GUI_DISABLE)
	GUICtrlSetState($InputX12, $GUI_DISABLE)
EndFunc

Func gui1enable()
	GUICtrlSetState($Checkbox1, $GUI_ENABLE)
	GUICtrlSetState($Checkbox2, $GUI_ENABLE)
	GUICtrlSetState($Checkbox3, $GUI_ENABLE)
	GUICtrlSetState($Checkbox4, $GUI_ENABLE)
	GUICtrlSetState($Checkbox6, $GUI_ENABLE)
	GUICtrlSetState($ComboX1, $GUI_ENABLE)
	GUICtrlSetState($ButtonA4, $GUI_ENABLE)
	GUICtrlSetState($ButtonA1, $GUI_ENABLE)

	GUICtrlSetState($InputX9, $GUI_ENABLE)
	GUICtrlSetState($InputX10, $GUI_ENABLE)
	GUICtrlSetState($InputX11, $GUI_ENABLE)
	GUICtrlSetState($InputX12, $GUI_ENABLE)
EndFunc

Func Check()
	If ($count >= $files[0]) Then
		GUICtrlSetState($ButtonF2, $GUI_DISABLE)
	ElseIf ($count <= 1) Then
		GUICtrlSetState($ButtonF1, $GUI_DISABLE)
	Else
		GUICtrlSetState($ButtonF1, $GUI_ENABLE)
		GUICtrlSetState($ButtonF2, $GUI_ENABLE)
	EndIf
EndFunc

Func ThreeDView2($ship)
	#Region ### START Koda GUI section ### Form=
	$Form2 = GUICreate("Form2", 1029, 586, 192, 126)
	GUISetBkColor(0x000000)
	$Pic3 = GUICtrlCreatePic("", 0, 0, 1028, 540)
	$ButtonF1 = GUICtrlCreateButton("<-- Previous", 368, 544, 131, 33)
	$ButtonF2 = GUICtrlCreateButton("Next -->", 536, 544, 131, 33)
	$LabelF1 = GUICtrlCreateLabel("Total images:", 8, 560, 78, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	$LabelF2 = GUICtrlCreateLabel("9999", 88, 560, 28, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	$LabelF3 = GUICtrlCreateLabel("Current image:", 144, 560, 83, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	$LabelF4 = GUICtrlCreateLabel("9999.jpg", 232, 560, 47, 18)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	$RadioF1 = GUICtrlCreateRadio("Sides", 728, 552, 113, 17)
	DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($RadioF1), "wstr", 0, "wstr", 0)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	$RadioF2 = GUICtrlCreateRadio("Cockpit", 856, 552, 113, 17)
	DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($RadioF2), "wstr", 0, "wstr", 0)
	GUICtrlSetFont(-1, 9, 400, 0, "Calibri")
	GUICtrlSetColor(-1, 0xFFFFFF)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	; 	DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Radio1), "wstr", 0, "wstr", 0)

	; Get list of files.
	$files = _FileListToArray("data\ships\"&$ship&"\3D View\")
	_ArrayDisplay($files)

	GUICtrlSetData($LabelF2, $files[0])

	GUICtrlSetData($Pic3, "data\ships\"&$ship&"\3D View\"&$files[1])
	MsgBox(0, "A", "data\ships\"&$ship&"\3D View\"&$files[1])
	Sleep(1000)
	GUICtrlSetData($Pic3, "data\ships\"&$ship&"\3D View\"&$files[2])
	MsgBox(0, "A", "data\ships\"&$ship&"\3D View\"&$files[2])
	Sleep(1000)
	GUICtrlSetData($Pic3, "data\ships\"&$ship&"\3D View\"&$files[3])
	MsgBox(0, "A", "data\ships\"&$ship&"\3D View\"&$files[3])
	; -----------------------

	$count = 1

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Form2)
				ExitLoop
			Case $ButtonF1
				; Backward
				$count = $count - 1

				MsgBox(0, "A", "data\ships\"&$ship&"\3D View\"&$files[2])

				ShellExecute("data\ships\"&$ship&"\3D View\"&$files[2])

				If FileExists("data\ships\"&$ship&"\3D View\"&$files[2]) = 0 Then
					MsgBox(0, "A", "nope!")
				EndIf
				GUICtrlSetData($Pic3, "data\ships\"&$ship&"\3D View\"&$files[2])
				GUICtrlSetData($LabelF4, $files[$count])

			Case $ButtonF2
				; Forward
				$count = $count + 1

				MsgBox(0, "A", "data\ships\"&$ship&"\3D View\"&$files[2]);$files[2])

				ShellExecute("data\ships\"&$ship&"\3D View\"&$files[2]);$files[2])

				If FileExists("data\ships\"&$ship&"\3D View\"&$files[2]) = 0 Then ;$files[2])
					MsgBox(0, "A", "nope!")
				EndIf
				$test = GUICtrlSetData($Pic3, "data\ships\"&$ship&"\3D View\3.jpg");$files[2])
				If $test = -1 Then
					MsgBox(0, "A", "B nope!")
				ElseIf $test = 0 Then
					MsgBox(0, "A", "C nope!")
				Else
					MsgBox(0, "A", "X nope!")
				EndIf
				GUICtrlSetData($LabelF4, $files[$count])
		EndSwitch

	WEnd
EndFunc

Func AboutDialog()
	#Region ### START Koda GUI section ### Form=
	$AboutForm = GUICreate("About", 322, 237, -1, -1)
	$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
	$Label1 = GUICtrlCreateLabel("Star Datapad", 120, 24, 88, 23)
	GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
	$Label2 = GUICtrlCreateLabel("Version: 0.0.0.8", 112, 48, 105, 23)
	GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
	$Label4 = GUICtrlCreateLabel("Under MIT open source licence.", 16, 160, 209, 23)
	GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
	$Label3 = GUICtrlCreateLabel("Copyright (c) Fade 2013", 16, 136, 158, 23)
	GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$ButtonR1 = GUICtrlCreateButton("&OK", 124, 208, 75, 25, 0)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($AboutForm)
				ExitLoop
			Case $ButtonR1
				GUIDelete($AboutForm)
				ExitLoop
		EndSwitch
	WEnd
EndFunc

Func OpenUrl($URL)
	;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question, Miscellaneous=Top-most attribute
	If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
	$iMsgBoxAnswer = MsgBox(262180,"Opening URL","Do you want to open the following URL in the default browser?" & @CRLF & $URL)
	Select
		Case $iMsgBoxAnswer = 6 ;Yes
			ShellExecute($URL)
		Case $iMsgBoxAnswer = 7 ;No

	EndSelect
EndFunc
